<?php
namespace App\Services\Article\EnterpriseArticle;

use App\Models\Article\Article;
use App\Services\Log\Log\LogLogic;

/**
 * 文章微应用逻辑层
 * Class ArticleLogic
 * @package App\Services\Article\Article
 */
class EnterpriseArticleLogic
{
//--------------------------------企业站前台开始------------------------------------------
    //指定分类下的文章列表
    public function articleList($data)
    {
        $_where['status'] = 1;
        $_where['release_status'] = 1;
        $_where['classify_id'] = $data['cid'];
        $_where['belong_to'] = 2;
        $rst = Article::where($_where)->orderBy('top','desc')->paginate(3);
        if ($rst === false) {
            return auto_failure($data, '文章列表获取失败！');
        }
        return auto_return($rst, '文章列表获取成功！');
    }
    //所有文章列表
    public function allList()
    {
        $_where['status'] = 1;
        $_where['release_status'] = 1;
        $_where['belong_to'] = 2;
        $rst = Article::where($_where)->orderBy('top','desc')->paginate(200);
        if ($rst === false) {
            return auto_failure('文章列表获取失败！');
        }
        return auto_return($rst, '文章列表获取成功！');
    }
    //指定分类下的文章详情
    public function assignInfo($data)
    {
        $_where['status'] = 1;
        $_where['release_status'] = 1;
        $_where['classify_id'] = $data['cid'];
        $_where['belong_to'] = 2;
        $rst = Article::where($_where)->select()->first();
        if ($rst === false) {
            return auto_failure($data, '文章获取失败！');
        }
        return auto_return($rst, '文章获取成功！');
    }

    /**
     * 文章详情
     */
    public function articleInfo($data)
    {
        $_where['status'] = 1;
        $_where['release_status'] = 1;
        $_where['id'] = $data['id'];
        $rst = Article::where($_where)->select()->first();
        if ($rst === false) {
            return auto_failure($data, '文章获取失败！');
        }
        return auto_return($rst, '文章获取成功！');
    }
//--------------------------------企业站前台结束------------------------------------------
}
